<template>
  <div class="app-container">
    <el-form :inline="true" :model="tower" class="demo-form-inline">
      <el-form-item label="塔号">
        <el-input v-model="tower.towerNo" placeholder="请输入塔号"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="result.data" border highlight-current-row style="width: 100%;margin-top:20px;">
      <el-table-column v-for="(value,key) in result.dataTitle" :key="key" :prop="key" :label="value" />
    </el-table>
  </div>
</template>

<script>
import { search } from '@/api/excel'
export default {
  data() {
    return {
      tower: {
        towerNo: ''
      },
      result: {
        data: [],
        dataTitle: []
      }
    }
  },
  methods: {
    onSubmit() {
      return new Promise((resolve, reject) => {
        search(this.tower.towerNo).then(response => {
          const { data,dataTitle } = response
          console.log(data)
          console.log(dataTitle)
          this.result.data = data
          this.result.dataTitle = dataTitle
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

